class Solution {
public:
    vector<vector<int>> levelOrder(Node* root) {
        vector<vector<int>> result;
        queue<Node*> que;
        if(root) que.push(root);
        while(!que.empty())
        {
            vector<int> res;
            for(int i=que.size(); i>0; --i)
            {
                Node* cur=que.front();
                que.pop();
                res.push_back(cur->val);
                for(auto node:cur->children) que.push(node); //孩子进队 
            }
            result.emplace_back(res);
        }
        return result;
    }
};